<script language="javascript">

 function kt()
 {

	var ten=document.getElementById("tenID");
	
		if(ten.value=="")
		{
		    document.getElementById("tenID").focus();
		    alert(" Ten dang nhap khong duoc de trong"); 
			return false;
		}
		if(!is_username(ten.value))
		{
			document.getElementById("tenID").focus();
			  alert("Khong duoc nhap ky tu dac biet"); 
				return false;
		}
	
	var pass1=document.getElementById("passID1");	
		if(pass1.value=="")
		{                document.getElementById("passID1").focus();
		    alert("PassWord khong duoc de trong"); 
			return false;
		}

	var pass2=document.getElementById("passID2");	
		if(pass1.value!=pass2.value)
		{	             
			alert("Hai o mat nhau nhap khong giong nhau");
			return false;
		}
 
	var dt=document.getElementById("dtID");	
		if(dt.value=="")
		{	document.getElementById("dtID").focus();
		    alert("Dien thoai khong duoc de trong"); 
			return false;
		}	
		if(!is_phone(dt.value))
		{
			  alert("So dien thoai ban nhap khong hop le, vui long cung cap so dien thoai chinh xac"); 
				return false;
		}
		
		
	var tenlh=document.getElementById("tenlhID");	
		if(tenlh.value=="")
		{	document.getElementById("tenlhID").focus();
		    alert("Ho va ten khong dc de trong"); 
			return false;
		}	
		
	var kt=document.getElementById("mailID");	
		if(kt.value=="")
		{	document.getElementById("mailID").focus();
		    alert("Email khong duoc de trong"); 
			return false;
		}	
		if(!is_email(kt.value))
		{
			  alert("Email nhap khong hop le"); 
				return false;
		}
		
		return true;
		
function is_phone(num) { return(/^(0121|0122|0123|0125|0127|0166|0167|0168|0169|0199|090|091|092|093|094|095|096|097|098)(\d{7})$/i).test(num)};
function is_username(value) { return (value.match(/^[0-9]/) == null) && (value.search(/^[0-9_a-zA-Z]*$/) > -1)};
function is_email(str) { return (/^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i).test(str)};

}

</script>


</head>

<body>

<form onSubmit="return kt();" id="dangky" method="POST" name="dangkythanhvien">
  <table width="621" border="0" align="center">
    <tr>
      <td width="160">Tên đăng nhập:</td>
      <td width="445"><input name="username" id="tenID" type="text" size="50" maxlength="25" /><font color="#FF0000"><strong>*</strong></strong></font>      </td>
    </tr>
    <tr>
      <td>Mật khẩu:</td>
      <td><input name="password" type="password" id="passID1" size="50"/>
      <font color="#FF0000"><strong>*</strong></strong></font>      
      </td>
    </tr>
    <tr>
      <td>Xác nhận mật khẩu:</td>
      <td><input name="password2" type="password" id="passID2"size="50" />
      <font color="#FF0000"><strong>*</strong></strong></font>      
      </td>
    </tr>
 </table>


  </table>
	  <table width="621" border="0" align="center">

	      <tr>
      <td>Điện thoại:</td>
      <td><input name="tel" type="text" id="dtID" size="35"  maxlength="11"/>
      <font color="#FF0000"><strong>*</strong></strong></font>      </td>
    </tr>
    <tr>
      <td width="161">Họ và tên:</td>
      <td width="450"><input type="text" name="fullname" id="tenlhID" size="35" maxlength="25"/><font color="#FF0000"><strong>*</strong></strong></font>     </td>
    </tr>
     <tr>
      <td>Địa chỉ Email</td>
      <td><input type="text" name="email" id="mailID" size="35"/><font color="#FF0000"><strong>*</strong></strong></font>      </td>
    </tr>
  	<tr><td align="center" colspan="2"><input name="dangky" type="submit" value="Đăng ký" /> 	    <input name="kodangky" type="reset" value="Nhập lại" /></td></tr>
  </table>
</form>
